home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 38 / Amiga Format CD38 (1999-03-15)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-04].iso / -screenplay- / hd_installers / -whdload- / whdload_dev / src / sources / keyboard.s < prev    next >
Text File  |  1998-07-16  |  2KB  |  66 lines

  1. ;*---------------------------------------------------------------------------
  2. ;  :Program.    keyboard.s
  3. ;  :Contents.    routine to setup an keyboard handler
  4. ;  :Version.    $Id: keyboard.s 1.1 1998/06/14 20:54:50 jah Exp $
  5. ;  :History.    30.08.97 extracted from some slave sources
  6. ;        17.11.97 _keyexit2 added
  7. ;  :Requires.    _keydebug    byte variable containing rawkey code
  8. ;        _keyexit    byte variable containing rawkey code
  9. ;        _debug        function to quit with debug
  10. ;        _exit        function to quit
  11. ;  :Copyright.    Public Domain
  12. ;  :Language.    68000 Assembler
  13. ;  :Translator.    Barfly V1.131
  14. ;  :To Do.
  15. ;---------------------------------------------------------------------------*
  16.  
  17. ; IN:    -
  18. ; OUT:    d0-d1/a0-a1 destroyed
  19.  
  20. _SetupKeyboard    lea    (.int2),a0
  21.         move.l    a0,($68)            ;set interrupt vector
  22.         lea    (_ciaa),a1
  23.         move.b    #CIAICRF_SETCLR|CIAICRF_SP,(ciaicr,a1)    ;allow ints from keyboard
  24.         tst.b    (ciaicr,a1)            ;clear all intreq
  25.         and.b    #~(CIACRAF_SPMODE),(ciacra,a1)    ;input mode
  26.         move.w    #INTF_PORTS,(intreq+_custom)
  27.         move.w    #INTF_SETCLR|INTF_INTEN|INTF_PORTS,(intena+_custom)
  28.         rts
  29.  
  30. .int2        movem.l    d0-d1/a1,-(a7)
  31.         lea    (_ciaa),a1
  32.         btst    #CIAICRB_SP,(ciaicr,a1)        ;check int reason
  33.         beq    .int2_exit
  34.         move.b    (ciasdr,a1),d0            ;read code
  35.         clr.b    (ciasdr,a1)            ;output LOW (handshake)
  36.         or.b    #CIACRAF_SPMODE,(ciacra,a1)    ;to output
  37.         not.b    d0
  38.         ror.b    #1,d0
  39.  
  40.         cmp.b    (_keydebug),d0
  41.         bne    .int2_1
  42.         movem.l    (a7)+,d0-d1/a1
  43.         move.w    (a7),(6,a7)            ;sr
  44.         move.l    (2,a7),(a7)            ;pc
  45.         clr.w    (4,a7)                ;ext.l sr
  46.         bra    _debug
  47.  
  48. .int2_1        cmp.b    (_keyexit),d0
  49.         beq    _exit
  50.     IFD _keyexit2
  51.         cmp.b    (_keyexit2),d0
  52.         beq    _exit
  53.     ENDC
  54.  
  55.         moveq    #3-1,d1                ;wait because handshake min 75 µs
  56. .int2_w1    move.b    (_custom+vhposr),d0
  57. .int2_w2    cmp.b    (_custom+vhposr),d0        ;one line is 63.5 µs
  58.         beq    .int2_w2
  59.         dbf    d1,.int2_w1            ;(min=127µs max=190.5µs)
  60.  
  61.         and.b    #~(CIACRAF_SPMODE),(ciacra,a1)    ;to input
  62. .int2_exit    move.w    #INTF_PORTS,(intreq+_custom)
  63.         movem.l    (a7)+,d0-d1/a1
  64.         rte
  65.  
  66.